import { getCate } from "@/utils/api/homeapi";
const topCategory = [
  "居家",
  "美食",
  "服饰",
  "母婴",
  "个护",
  "严选",
  "数码",
  "运动",
  "杂货",
];
export default {
  namespaced: true,
  state: {
    cate: topCategory.map((item) => {
      return { name: item };
    }),
    cateList: [],
    nowCateIndex: 0,
  },
  mutations: {
    // 设置cate
    setCate(state, arr) {
      state.cate = arr;
      state.cateList = arr;
    },
    //设置当前点击的下标
    setCateIndex(state, key) {
      state.nowCateIndex = key;
    },
  },
  actions: {
    /* 设置分类数据 */
    async asyncSetCate({ commit }) {
      let res = await getCate();
      commit("setCate", res.result);
    },
    /* 设置详情页数据 */
    // async asyncSetDetail({ commit }) {
      // let res = await getCate();
      // commit("setCate", res.result);
    // },
  },
};
